package cn.zhaoyan.serviceimpl;

import cn.zhaoyan.bean.Customer;
import cn.zhaoyan.bean.PageBean;
import cn.zhaoyan.dao.Customerdao;

import cn.zhaoyan.daoimpl.Customerdaoimpl;

import cn.zhaoyan.service.CustomerService;

import java.util.List;
import java.util.Map;

public class CustomerServiceipml implements CustomerService{
    Customerdao dao = new Customerdaoimpl();

    @Override
    public List<Customer> queryService() {

        List<Customer> list = dao.customerdao();
        return list;
    }

    @Override
    public void serviceSsc(String id) {
        dao.daoQuery(id);
    }

    @Override
    public void batchDelete(String[] select) {
     dao.batchDelete(select);
    }

    @Override
    public boolean addService(Customer customer) {
        Customer selectdao = dao.selectdao(customer);
        if (selectdao == null){
            dao.insertdao(customer);
            return true;
        }else {
            return false;
        }

    }

    @Override
    public Customer updateService(String id) {
        Customer updatedao = dao.updatedao(id);
        return updatedao;
    }

    @Override
    public void updateService1(Customer customer) {
      dao.updatedao1(customer);

    }
    /**
     * 分页查询
     * @param pageBean
     * @param parameterMap
     * @return
     */
    @Override
    public PageBean findCustomerService(PageBean pageBean, Map<String, String[]> parameterMap) {
        //查询总条数
     pageBean.setTotalCounts( this.dao.getCustomerCount(parameterMap));
     //分页显示数据
     pageBean.setList(this.dao.getCustomerLiset(pageBean.getStartIndex(),pageBean.getPageSize(),parameterMap));
        return pageBean;
    }


}
